package com.example.kotlinlearn.jetpack

import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.example.kotlinlearn.MyApplication

class MyObserver(val lifecycle: Lifecycle): LifecycleObserver{
    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    fun activityStart(){
        Log.d("我的活动生命周期感知器", "activityStart: "+MyApplication.context.packageName)
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    fun activityPause(){
        Log.d("我的活动生命周期感知器", "activityPause: 活动暂停")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun activityDestroy(){
        Log.d("我的活动生命周期感知器", "activityDestroy:活动销毁 ")
    }
}